home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-06 | 3.9 KB | 169 lines | [TEXT/CWIE] |
- //========================================================================
- // Application: QTICSampleApp
- //
- // Description: This application demonstrates the integration of
- // QuickTime™ IC functionality.
- //
- // Author: Mike Bitz
- // Developer Technical Support
- // Apple Computer, Inc.
- //
- // History: 25-Apr-97 original development (mwb)
- //
- // Copyright © 1997 Apple Computer, Inc., All Rights Reserved
- //
- // You may incorporate this sample code into your applications without
- // restriction, though the sample code has been provided "AS IS" and the
- // responsibility for its operation is 100% yours. However, what you are
- // not permitted to do is to redistribute the source as "DSC Sample Code"
- // after having made changes. If you're going to re-distribute the source,
- // we require that you make it clear in the source that the code was
- // descended from Apple Sample Code, but that you've made changes.
- //========================================================================
-
-
- #include "prototypes.h"
- #include "application.h"
- #include "globals.h"
- #include <QTIC.h>
-
- extern QTICControls gCameraControls;
- extern QTICActionFilterWithRefConUPP gCallBack;
-
- //================= Main =================
- void main (void)
- {
- InitMac ();
- InitQTIC ();
- SetupMenus ();
- MainEventLoop ();
- }
-
- //================= InitMac =================
- void InitMac (void)
- {
- OSErr err = noErr;
- THz curZone;
-
- // Expand the application heap zone
- MaxApplZone ();
- curZone = GetZone();
- if ( curZone->moreMast < kMasterBlockSize ) {
- curZone->moreMast = kMasterBlockSize;
- MoreMasters();
- }
-
- InitGraf (&qd.thePort);
- InitFonts ();
- InitWindows ();
- InitMenus ();
- TEInit ();
- InitDialogs (0L);
- InitCursor ();
- FlushEvents (0, everyEvent);
-
- err = EnterMovies ();
- if (err != noErr)
- SysBeep (1);
- }
-
- //================= MainEventLoop =================
- void MainEventLoop (void)
- {
- OSErr err = noErr;
- EventRecord event;
- Boolean ignored;
-
- while (gDone == false)
- {
- ignored = WaitNextEvent (everyEvent, &event, 0, nil);
- DoEvent (&event);
- }
-
- // Dispose QTIC stuff
- if (gCameraControls != nil && gCallBack != nil)
- {
- // Dispose action filter.
- err = QTICCRemoveActionFilter (gCameraControls, gCallBack, 0);
- DisposeRoutineDescriptor (gCallBack);
-
- err = CloseComponent (gCameraControls);
- gCameraControls = nil;
- }
- }
-
- //================= DoEvent =================
- void DoEvent (EventRecord *eventPtr)
- {
- OSErr err = noErr;
- char theChar;
- Boolean gotEvent = false;
- WindowPtr theWindow = nil;
-
- // QTIC event handling
- if (gCameraControls != nil)
- {
- if (QTICCEvent (gCameraControls, eventPtr))
- {
- // This event was handled by QTIC, so update the panel menu accordingly.
- UpdatePanelSpecificMenu ();
-
- // Disable the Close Window menu item if that QTIC event caused the last
- // window to close.
- UpdateCloseWindowItem ();
- }
- else
- {
- // Give idle time to all panels
- QTICCIdle (gCameraControls);
- }
- }
-
- // Handle standard events
- switch (eventPtr->what)
- {
- case mouseDown:
- HandleMouseDown (eventPtr);
- break;
-
- case keyDown:
- case autoKey:
- theChar = eventPtr->message & charCodeMask;
- if ((eventPtr->modifiers & cmdKey) != 0)
- {
- HandleMenuChoice (MenuKey (theChar));
- }
- break;
- }
- }
-
- //================= HandleMouseDown =================
- void HandleMouseDown (EventRecord *eventPtr)
- {
- WindowPtr theWindow = nil, frontWindow = nil;
- short thePart;
- long menuChoice;
- MenuHandle hFileMenu = nil;
-
- thePart = FindWindow (eventPtr->where, &theWindow);
- switch (thePart)
- {
- case inMenuBar:
- menuChoice = MenuSelect (eventPtr->where);
- HandleMenuChoice (menuChoice);
- break;
-
- case inSysWindow:
- SystemClick (eventPtr, theWindow);
- break;
-
- case inDrag :
- DragWindow (theWindow, eventPtr->where, &qd.screenBits.bounds);
- break;
-
- case inContent:
- if (theWindow != FrontWindow ())
- SelectWindow (theWindow);
- break;
- }
- }